<?php

header('content-type:text/html; charset=utf8');

// $name = '张三';

// echo "<h1>11111{$name}</h1>";

$server = 'localhost:3306';
$username = $password = 'root';
$dbname = '2020';


$conn = mysqli_connect($server, $username, $password, $dbname);

if(!$conn) {
  die('数据库连接失败');
}

// echo '数据库连接成功';



// echo json_encode((array('name' => '张三')));

$sql = "select * from userinfo";

$result = mysqli_query($conn, $sql);    // 拿到结果集

$data = mysqli_fetch_assoc($result);    // 拿单条数据

// var_dump($data);

echo json_encode($data);
